﻿//======================================================================
//
//        Copyright (C) 2015   
//        All rights reserved
//
//        filename : PutOutCard
//        description : 半成品/成品卡出库

//        created by XXX at  20150821
//
//======================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CardLogistics.Web.Components;
using System.Data;

namespace CardLogistics.Web.MainPage.PutOutCard.PutOutCard
{
    public partial class Detail : BasePage
    {
        private static readonly CardLogistics.DAL.PutOutCard.PutOutCardData DAL = new DAL.PutOutCard.PutOutCardData();
        private static readonly CardLogistics.DAL.PutOutCard.PutOutCard_DetailData DDAL = new CardLogistics.DAL.PutOutCard.PutOutCard_DetailData();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void InitControl()
        {
            string _key = Request.QueryString["id"];
            WebUserControl_AppInfo1.InfoID = _key;
            WebUserControl_AppInfo1.UserID = LoggedUser.ID;
            if (!string.IsNullOrEmpty(_key))
            {
                CardLogistics.Model.PutOutCard.PutOutCard pData = DAL.GetModel(_key);
                SetWebControls(this.Page, pData);
             
                if (pData!= null)
                {
                    //出库日期
                    if (pData.PUTOUTCARDDATE != null)
                    {
                        PUTOUTCARDDATE.Text = DateTime.Parse(pData.PUTOUTCARDDATE.ToString()).ToString("yyyy-MM-dd");
                    }
                }
                DataTable dt = DDAL.GetInfoByPutOutCardId(pData.ID);//查询卡片出库详细信息
                if (dt.Rows.Count>0)
                {
                    rptDetailList.DataSource = dt;
                    dt.DefaultView.Sort = "StartNo ASC,EndNo ASC";
                    rptDetailList.DataBind();
                    SUPPLIERSNAME.Text = dt.Rows[0]["SuppliersName"].ToString(); //供应商名称
                    CARDTYPENAME.Text = dt.Rows[0]["CardTypeName"].ToString(); //卡片名称
                    //StatusName.Text = dt.Rows[0]["StatusName"].ToString(); //卡片状态
                }
               
            }
        }
    }
}